package com.uphone.kingmall.activity.personal;

import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.china.zhuoyue.R;
import com.lzy.okgo.model.Response;
import com.uphone.kingmall.base.BaseActivity;
import com.uphone.kingmall.bean.UserShopInfoBean;
import com.uphone.kingmall.listener.onNormalRequestListener;
import com.uphone.kingmall.utils.CommonUtil;
import com.uphone.kingmall.utils.GsonUtils;
import com.uphone.kingmall.utils.MyUrl;
import com.uphone.kingmall.utils.OkGoUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * <pre>
 *     author : radish
 *     e-mail : 15703379121@163.com
 *     time   : 2019/3/28
 *     desc   :
 * </pre>
 */
public class ShangJiaRuZhuSuccessActivity extends BaseActivity {
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_psd)
    TextView tvPsd;
    @BindView(R.id.ll_2)
    LinearLayout ll2;

    @Override
    public int getLayoutContentId() {
        return R.layout.kingmall_activity_shop_register_success;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {

        OkGoUtils.normalRequest(MyUrl.getShopApplyInfo, null, new onNormalRequestListener() {


            @Override
            public void onSuccess(String body, int code) {
                if (code == 0) {
                    UserShopInfoBean bean = GsonUtils.getGson().fromJson(body, UserShopInfoBean.class);
                    if (bean != null && bean.getApplyInfo() != null &&
                            !TextUtils.isEmpty(bean.getApplyInfo().getLoginName()) &&
                            !TextUtils.isEmpty(bean.getApplyInfo().getPassword())) {
                        tvName.setText("您的店铺账号：" + bean.getApplyInfo().getLoginName());
                        tvPsd.setText("密码：" + bean.getApplyInfo().getPassword());
                    } else {
                        CommonUtil.startIntent(ShangJiaRuZhuSuccessActivity.this, ShangJiaRuZhuActivity.class);
                        finish();
                    }
                }

            }

            @Override
            public void onError(Response<String> response) {

            }
        });
    }

    @OnClick(R.id.iv_back)
    public void onViewClicked() {
        finish();
    }
}
